package com.fzkj.shejimoshi.adapter.media;

import com.fzkj.shejimoshi.adapter.AudioType;
import com.fzkj.shejimoshi.adapter.MediaAdapter;
import com.fzkj.shejimoshi.adapter.advancemedia.Mp4Player;
import com.fzkj.shejimoshi.adapter.advancemedia.VlcPlayer;

/**
 * @DESCRIPTION: TODO 使用audioPlay，调用不属于MediaPlayer的方法（通过MediaAdapter）
 * @AUTHOR: AnotherOne
 * @DATE: 2021/8/12 16:23
 */
public class AudioPlayer implements MediaPlayer {

    MediaAdapter adapter;

    @Override
    public void play(AudioType audioType, String fileName) {
        if (audioType == AudioType.MP3){
            System.out.println("播放 mp3 格式 -> " + fileName);
        } else if (audioType == AudioType.MP4){
            adapter = new MediaAdapter(new Mp4Player());
            adapter.play(audioType, fileName);
        } else if (audioType == AudioType.VLC){
            adapter = new MediaAdapter(new VlcPlayer());
            adapter.play(audioType, fileName);
        } else {
            System.out.println("=== UnSupportMediaType ===");
        }
    }
}
